package com.example.demo.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

@WebFilter("/*")
public class EncodingFilter implements Filter {
    private static final String DEFAULT_ENCODING="utf-8";

    public void destroy(){

    }
    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)throws ServletException, IOException{
        req.setCharacterEncoding(DEFAULT_ENCODING);
        resp.setCharacterEncoding(DEFAULT_ENCODING);
        chain.doFilter(req,resp);
    }

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
    }
}
